package cn.datawin.cmppprovider.pool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * Created by Satroler on 2017/7/11.
 */
@Service("executePoolService")
public class ExecutePoolService {
    private static ExecutorService executor = Executors.newCachedThreadPool();

    public Future submit(Callable task){
        return executor.submit(task);
    }

    public boolean cancel(Future future, boolean mayInterruptIfRunning){
        return future.cancel(mayInterruptIfRunning);
    }

}
